Managing Memory

You can customize default behavior for how the RTX64 Subsystem interacts with Windows during memory allocation from the Manage memory Control Panel page. See below for complete descriptions of the available settings.

NOTE: Some changes to RTX64 Control Panel require a restart of the RTSS Subsystem.

Sections in this Topic:

 


Opening this Page in RTX64 Control Panel

To open this page in the Control Panel:

  1. In the Start menu, navigate to RTX64 4.5 Runtime and click RTX64 Control Panel.
  2. Click Configure the RTSS Subsystem > Manage memory.

Understanding the Memory Profile

Under Memory profile, you can configure the approximate amount of system memory available to RTX64 (see Calculating Available System Memory below) and view memory usage information for RTX64 components. When changes are made to allocation values on the page, the usage values update accordingly. This provides a helpful approximation of how memory will be allocated initially, and whether there is enough remaining memory to run the number of RTSS processes you require.

Calculating Available System Memory

The amount of memory available to RTX64 is calculated using two primary values which you can specify under Memory profile:

Setting Description Action
Available system memory

The amount of available system memory, in gigabytes. The default value is based on the amount of available memory detected by the RTX64 installer.

You can view the current amount of available system memory in the Windows Task Manager under Performance > Memory:

To change the amount of available system memory, note the Available value in the Windows Task Manager and enter it in the text field in the RTX64 Control Panel.

NOTE: It is good practice to periodically compare the amount of available system memory in the RTX64 Control Panel with the actual amount in the Windows Task Manager.

Percentage expected to be used by Windows

The percentage of the Available system memory that is expected to be used by Windows applications running in conjunction with your real-time applications. The default is 50%. The remaining percentage of the available system memory is the amount available to RTX64.

Available system memory (GB) - Memory used by Windows (%) = Available RTX64 memory (%)

The acceptable range for this value is 1-99%.

To change this percentage, enter a new value in the text field.

To approximate this value, run your full application in Windows and RTX64, view the memory usage, and customize this value accordingly.

 

NOTE: These values are not enforced. They are used for memory allocation calculations within the control panel.

RTX64 Component Memory Usage

NOTE: External allocations can be set via the Control Panel. However, memory usage calculations factor both external and internal memory resource allocations.

NOTE: These component usage values apply only to local memory.

Component Description
Initial Subsystem usage

The initial amount of available memory used by the RTX64 Subsystem. This is mainly used for internal Subsystem structures.

For more information, see Allocation Spaces in Local Memory.

Monitoring usage

The amount of memory used by RTX64 monitoring.

NOTE: When Enable instrumentation within the Subsystem for monitoring real-time applications is not checked in the Configure the RTSS Subsystem > Change Monitoring settings page, this value is grayed-out, and its usage is not factored in memory calculations.

Initial NAL usage

The initial amount of memory used by the Network Abstraction Layer (NAL). This initial value assumes one enabled interface in addition to the Virtual NIC. If more interfaces are enabled, you must either increase this value accordingly or enable the Auto expand setting.

Note that NAL memory cannot be disabled.

Initial TCP/IP Stack usage

The initial amount of memory allocated to the TCP/IP Stack, including the heap but not including memory allocated by device drivers at startup. This initial value assumes one enabled interface in addition to the Virtual NIC. If more interfaces are enabled, you must either increase this value accordingly or enable the Auto expand setting.

NOTE: When the TCP/IP Stack is not licensed, this value is grayed-out and is not factored in memory calculations.

Remaining memory available to RTSS processes The estimated remaining memory available to RTSS processes, based on all other allocations.
Approximate number of concurrent RTSS processes that can run

The approximate number of RTSS processes that can run concurrently, based on the Remaining memory available to RTSS processes value.

NOTE: Default MSpaces can be changed per-process at process startup, which is why this is an approximation.

Managing Subsystem and Application Memory Allocation Behavior

You can configure RTX64's default memory allocation behavior to request memory from the local pool or from Windows.

To set Subsystem and application memory allocation defaults:

Select an option to configure default memory allocation behavior:

When this option is selected, you can configure the amount of memory to allocate to the RT-TCP/IP Stack heap (in kilobytes). Note that this does not include memory allocated by device drivers at startup.

Zeroing Memory on Allocation

The memory allocated by malloc, or similar C-Runtime functions is not initialized to zero according to the C99 specification, which Windows follows. To maintain backwards compatibility, RTX64 provides a Zero memory on allocation setting.

This setting is enabled by default.

NOTE: Zeroing memory may cause a performance lag. If this lag is not acceptable, disable Zero memory on allocation. When disabled, memory requests from some C-Runtime functions or RTAPIs will not be initialized to zero at allocation. However, by definition, memory requests from calloc/_recalloc, VirtualAlloc, and HeapAlloc/HeapReAlloc with the HEAP_ZERO_MEMORY flag will be initialized to zero at allocation.

For more information, see Zeroing Memory on Allocation.

You must restart RTX64 for changes to take effect. If you plan to make additional changes that require a restart of the Subsystem, make all of the changes first and then restart RTX64 when you are finished.

Using Local Memory

The local memory configuration contains multiple allocation spaces (MSpaces) that make up a system: the RTX64 Subsystem, NAL, and RT-TCP/IP Stack along with each RTSS process and Windows proxy process. The RTX64 Subsystem, networking components, and each RTSS process and proxy process, has an internal MSpace for internal objects and bookkeeping, and an external MSpace for process allocations. Memory needs from the Subsystem for internal objects are allocated within the internal allocation space. Memory allocation requests from RTAPIs, including from C-Runtime libraries, are allocated within the external allocation space. For more information, see Allocation Spaces in Local Memory.

Memory is allocated from one of the process MSpaces unless the memory is required to remain over process exit, such as memory for IPC objects and cross-process shared memory. Such allocations are made from the Subsystem’s MSpace.

When local memory is used, the Subsystem’s external MSpace is created when the first memory request is made, unless commit is selected, in which case the memory is allocated as soon as the Subsystem starts. Individual process external MSpaces behave similarly. Memory is allocated on the first memory request unless RtssRun or RTX64 Task Manager is used to start the process or when a Native or Managed API is passed the initial size of the process’s MSpaces. It provides deterministic behavior for normally non-deterministic functions, as well as greater flexibility and functionality after a system stop (blue screen).

You can specify the initial size of the local memory allocation spaces (MSpaces) in kilobytes. If RTSS applications exhaust the memory you initially allocate, you can configure each MSpace to automatically expand.

Note that expand will request memory when an allocation request cannot be fulfilled with the remaining memory available in an MSpace. Requesting memory from Windows introduces non-deterministic behavior during the expansion of the pool and cannot be called in the shutdown handler. To avoid this scenario, it is important to be aware of your applications' memory needs and specify an initial MSpace size that will support them. For more information on using local memory with RTX64, see Allocation Spaces in Local Memory.

Process Memory Allocation Space

Use these settings to configure application local memory allocation behavior.

Setting Description Action
Minimum size for internal MSpace (kilobytes) The minimum size of each RTSS processes' internal MSpace.

Drag the slider or enter a new value in the text field.

NOTE: Changes to this value are committed automatically.

Minimum size for external MSpace (kilobytes) The minimum size of each RTSS processes' external MSpace.

Drag the slider or enter a new value in the text field.

NOTE: Changes to this value are committed automatically.

Auto expand MSpaces

You can configure RTX64 to automatically request additional memory (expand) once the MSpace is exhausted. Note that expanding memory introduces non-deterministic behavior.

This setting determines whether an RTSS processes' MSpaces will expand to meet memory demands.

To automatically expand MSpaces, select the check box and set the Expand size (default). To do this, either drag the slider or enter a value in the text field.

To turn off auto expand, clear selection of the check box.

NOTE: If the memory requested is not available, your memory allocation request will fail.

Auto shrink MSpaces Determines whether to shrink MSpaces when freeing memory allocated directly from the Local Pool.

To automatically shrink MSpaces, select the check box (default).

To turn off auto shrink, clear selection of the check box.

System Process Memory Allocation Space

Use these settings to configure Subsystem local memory allocation behavior.

Setting Description Action
Minimum size for internal MSpace (kilobytes) The minimum size of the system process's internal MSpace.

Drag the slider or enter a new value in the text field.

NOTE: Changes to this value are committed automatically.

Minimum size for external MSpace (kilobytes) The minimum size of the system process's external MSpace.

Drag the slider or enter a new value in the text field.

NOTE: Changes to this value are committed automatically.

NOTE: All process shared memory and IPC object memory allocations come from this value.

Commit at Subsystem startup Determines whether to allocate Non-Paged memory from Windows into the Local Pool of the MSpace at Subsystem startup.

To commit the MSpace memory at startup, select the check box.

To not commit at Subsystem startup, clear selection of the check box.

Auto expand MSpaces

You can configure RTX64 to automatically request additional memory (expand) once the MSpace is exhausted. Note that expanding memory introduces non-deterministic behavior.

This setting determines whether the system process's MSpaces will expand to meet memory demands.

To automatically expand MSpaces, select the check box and set the Expand size. To do this, either drag the slider or enter a value in the text field.

To turn off auto expand, clear selection of the check box.

IMPORTANT! When Auto expand MSpaces is disabled for the Subsystem, you will be responsible for configuring the amount of memory the Subsystem has for internal and external resources for the entire system. This includes Networking components (NAL and RT-TCP/IP Stack) and other tools and utilities provided with the RTX64 Runtime. If the Subsystem does not have enough available memory, real-time processes will fail to run or fail to create IPC objects with ERROR_NOT_ENOUGH_MEMORY. See the MiniTutorial Best Practices for Disabling Auto Expand MSpaces for recommendations on how to proceed with Auto expand MSpaces disabled.

Auto shrink MSpaces Determines whether to shrink MSpaces when freeing memory allocated directly from the Local Pool.

To automatically shrink MSpaces, select the check box.

To turn off auto shrink, clear selection of the check box.

Network Memory Allocation Space

Use these settings to configure the memory allocation spaces for the Network Abstraction Layer (NAL) and RT-TCP/IP Stack.

Network Abstraction Layer (NAL) memory allocation space
Setting Description Action
Minimum size for external MSpace (kilobytes)

The minimum size of the NAL process's external MSpace. The minimum is 64 kilobytes. The default value is 1024 kilobytes.

This size will differ based on the number of enabled interfaces.

You can use the following formula to determine the amount of memory you need to allocate:

Minimum size for external MSpace = 128K + (64K * numberOfEnabledInterfaces)

Drag the slider or enter a new value in the text field.

NOTE: Changes to this value are committed automatically.

Commit at Subsystem startup Determines whether to allocate Non-Paged memory from Windows into the Local Pool of MSpace at NAL process startup.

To commit the external MSpace memory at startup, select the check box.

To not commit at Subsystem startup, clear selection of the check box.

Auto expand MSpaces

You can configure RTX64 to automatically request additional memory (expand) once the MSpace is exhausted. Note that expanding memory introduces non-deterministic behavior.

This setting determines whether the NAL process' MSpaces will expand to meet memory demands.

To automatically expand MSpaces, select the check box and set the Expand size. To do this, either drag the slider or enter a value in the text field.

To turn off auto expand, clear selection of the check box.

Note that Auto expand MSpaces cannot be turned off when the minimum size is too small.

TCP/IP Stack memory allocation space

NOTE: The RT-TCP/IP Stack settings are grayed-out when the RT-TCP/IP Stack is not licensed or licensed but not started.

NOTE: The Control Panel displays a warning when proposed changes to the TCP/IP Stack memory configuration will result in insufficient memory, based on the number of enabled interfaces as well as other considerations.

Setting Description Action
Minimum size for external MSpace (kilobytes)

The minimum size of the TCP/IP Stack process's external MSpace. The minimum is 64 kilobytes. The default value is 6272 kilobytes.

This value needs to be large enough to support RT-TCP/IP Stack heap allocation and must be at least the RT-TCP/IP Stack heap allocation size plus 2176 kilobytes.

You can use the following formula to determine the amount of memory you need to allocate:

Minimum size for external MSpace = StackHeap(k) + 2176k + (64k * numberOfEnabledInterfaces)

Drag the slider or enter a new value in the text field.

NOTE: Changes to this value are committed automatically. The RT-TCP/IP Stack will need to be restarted if it is running.

MSpace memory allocated to the TCP/IP Stack heap (kilobytes, not including memory allocated by device drivers at startup)

The TCP/IP Stack must allocate all necessary memory on start up to be deterministic. This allocated memory value should be large enough to include all transmit and receive buffers.

  • The minimum allowable value is 2048 kilobytes.
  • The maximum allowable value is 4 gigabytes.

You can use the following formula to determine the amount of memory you need to allocate:

Stack heap = 2048K + (50K * numberOfEnabledInterfaces) + (200K * NumberOfActiveConnections)

NOTE: This does not include memory allocated by the NIC drivers at startup.

NOTE: This memory is allocated from the MSpace, so the TCP/IP Stack heap size MUST be 2176 KB less than the Minimum size for external MSpace (kilobytes) value if Auto expand MSpaces is not enabled.

Enter a value in the text field.

Auto expand MSpaces

You can configure RTX64 to automatically request additional memory (expand) once the MSpace is exhausted. Note that expanding memory introduces non-deterministic behavior.

This setting determines whether the TCP/IP Stack process' MSpaces will expand to meet memory demands.

NOTE: If the Minimum size for external MSpace value is less than the MSpace memory allocated to the TCP/IP Stack heap value, Auto expand MSpaces cannot be disabled.

To automatically expand MSpaces, select the check box and set the Expand size. To do this, either drag the slider or enter a value in the text field.

To turn off auto expand, clear selection of the check box.

Note that Auto expand MSpaces cannot be turned off when the minimum size is too small to support the Stack.

Managing Monitoring Memory Usage

Drag the slider or enter a value in the text field to specify the amount of contiguous non-paged memory used by the Subsystem for the collection of monitored events. This memory is allocated from Non-Paged pool memory and it is allocated when monitoring is enabled.

NOTE: This section is grayed-out when monitoring is not enabled.

NOTE: Depending on the number of events you are monitoring and the frequency of those events, you might need to increase this value to avoid receiving Data Lost events due to insufficient internal buffer space. If you encounter Data Lost events, increase the amount of memory dedicated to monitoring (and consider monitoring fewer kinds of events).

RELATED Topics: